create or replace function insertDepartmentType(
	out xml, inout xml
	)
as
$$
	declare
		-- parameters and aliases
		executeResultData	alias 	for $1;
		departmentTypeData	alias	for $2;
		
		-- variable for node data
		vIdDepartmentType	integer := null;
		vNameDepartmentType text	:= null;
		
		-- node path
		vIdNode varchar(100)	:= '/departmenttype/@id';
		vNameNode varchar(100)	:= '/departmenttype/departmenttypename';
		
	begin
		-- get data from xml
		-- vIdDepartmentType := cast(extract_value(vIdNode, departmentTypeData) as integer);
		vNameDepartmentType := extract_value(vNameNode, departmentTypeData);
		
		-- insert data
		insert into DepartmentType(nameDepartmentType)
			values(vNameDepartmentType)
			returning idDepartmentType into vIdDepartmentType;
			
		-- form output data
		departmentTypeData := departmentType2XML(vIdDepartmentType, vNameDepartmentType);
		executeResultData := statusCall(successCode(), insertText());
		
		return;
	end;
$$
language plpgsql VOLATILE;
		
		